home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 25 / Cream of the Crop 25.iso / disk / ncom23.zip / WINDOWS / MLISTBOX.TXT < prev    next >
Text File  |  1992-10-26  |  12KB  |  385 lines

  1.                                 MLISTBOX.VBX
  2.  
  3. MLISTBOX.VBX is a custom control for Microsoft Visual Basic which provides
  4. support for extended- and multiple-selection listboxes as well as the
  5. standard single-selection listboxes that are built into Visual Basic.
  6.  
  7. This product is (pseudo) shareware.  Information on distribution rights is
  8. provided at the end of this file.
  9.  
  10. I welcome any comments, criticisms, suggestions, etc.  I can be reached
  11. via e-mail at:
  12.  
  13.         warninm@xanth.cs.orst.edu
  14.  
  15. (I would also be interested to know where you obtained your copy of 
  16. MLISTBOX.)
  17.  
  18. Mike Warning
  19. Oct 25, 1992
  20.  
  21.  
  22.                           HOW TO USE CUSTOM CONTROLS
  23.  
  24. For those of you unfamiliar with using custom controls in Visual Basic, it is
  25. really easy.  First, copy the file ending with .VBX to your windows
  26. directory.  The start up Visual Basic and select 'Add File...' from the 
  27. 'File' menu.  Locate the custom control file (.VBX file) that you wish to
  28. use and select it, then click 'OK'.  The icon representing the custom control
  29. should appear in the toolbox window and may be used just like any of the
  30. standard controls.  If you then save your project, the custom control will
  31. be reloaded automatically the next time you open your project.
  32.  
  33.  
  34.                                   REFERENCE
  35.  
  36. Since I have made every effort to preserve the functionality of the original
  37. single-selection listbox in my version, I will only address those properties
  38. that are new or that I have expanded.  For information on the standard
  39. properties not covered here, refer to the Visual Basic documentation.
  40.  
  41. A number in parenthesis after the name of the property specifies what version
  42. of MListbox first supported it.
  43.  
  44. Note that when I refer to 'multiple-selection listboxes' below, I really
  45. mean 'multiple- or extended-selection listboxes'.
  46.  
  47.  
  48. AutoRedraw - (1.1)
  49.     Controls how the listbox is updated when an item is added or removed.
  50.     The default is TRUE.
  51.  
  52.     If AutoRedraw is TRUE, the listbox acts just like the standard single-
  53.     selection VB listbox - the entire box is redrawn at the end of an 
  54.     event procedure (or during a DoEvents() call) if an item has been 
  55.     added or removed.
  56.  
  57.     If AutoRedraw is FALSE, then the listbox will not get redrawn until
  58.     you change it back to TRUE.  This is useful when you need to add a 
  59.     a lot of items in a loop with a DoEvents() call and want to avoid
  60.     flashing.
  61.  
  62.     Example:
  63.         ...
  64.         mlistbox1.AutoRedraw = FALSE
  65.         For i = 1 to 50
  66.             mlistbox1.AddItem Format$(i)
  67.             e = DoEvents()
  68.         Next i
  69.         mlistbox1.AutoRedraw = TRUE
  70.         ...
  71.  
  72.  
  73. Empty -
  74.     When reading this property, a TRUE will be returned if the listbox is    
  75.     empty, otherwise a FALSE will be returned.  Writing any value to this
  76.     property will force the listbox to reset, discarding any items that
  77.     it contains.
  78.  
  79.     Example:
  80.         ...
  81.         mlistbox1.Empty = TRUE          ' Clear listbox
  82.         ...
  83.  
  84.  
  85. FindString -
  86.     This property is used to find strings in a listbox.  When this property
  87.     is set, the 'FindIndex' property may then be checked to find the index
  88.     of the first string in the listbox matching the FindString.  After
  89.     a string is found, this property will reset to the value of the string
  90.     in the listbox.
  91.  
  92.     FindString will reset to null ("") if there is no string in the listbox
  93.     matching the value that you gave it.
  94.  
  95.     Example:                            
  96.         ...
  97.         mlistbox1.FindString = "J"      ' Find an item beginning with "J"
  98.         If mlistbox1.FindString = "John" Then
  99.         ...
  100.  
  101.     See Also:
  102.         FindIndex
  103.  
  104.  
  105. FindIndex -
  106.     This property hold the index of the string found using FindString.  It
  107.     will be set to -1 if there is no matching string.
  108.  
  109.     Example:
  110.         ...
  111.         mlistbox1.FindString = "J"      ' Find an item beginning with "J"
  112.         If mlistbox1.FindIndex = -1 then        ' There isn't any
  113.         ...
  114.  
  115.     See Also:
  116.         FindString
  117.  
  118.  
  119. hWnd -
  120.     This property is the window handle associated with the listbox and is
  121.     exactly like the 'hWnd' property that forms have.  This function is
  122.     useful when a window handle must be passed to a Windows API function
  123.     or other DLL function.
  124.  
  125.     Example:
  126.         ...
  127.         word = GetWindowWord(mlistbox1.hWnd, GWW_ID)
  128.         ...
  129.  
  130.  
  131. ItemData -
  132.     This property associates a long-integer value with an item in the 
  133.     listbox.  For example, if you have a listbox containing names, you could
  134.     put there ages (or whatever) in the ItemData for a particular item.
  135.  
  136.     This property is similar to the standard 'Tag' property, except that
  137.     it is numeric, and each item in the control can have it's own data.
  138.  
  139.     Example:
  140.         ...
  141.         mlistbox.ItemData(3) = 34
  142.         ...
  143.  
  144.  
  145. ListIndex -
  146.     For single-selection listboxes, ListIndex returns the index of the 
  147.     currently selected item.  For multiple-selection listboxes, ListIndex
  148.     returns the index of the last item that the user clicked on, the
  149.     'Selected' property may then be used to find out if that item is 
  150.     currently selected or not.
  151.  
  152.     If there is no current selection, single-selection listboxes will
  153.     return -1.  If no selection has ever been made, multiple-selection
  154.     listboxes will return 0.
  155.  
  156.     NOTE:  The Windows SDK says that this should not work for multiple-
  157.     selection listboxes; however, it seems to work fine under Windows 3.0
  158.     and 3.1.  Therefore, I cannot guarantee that this property will work 
  159.     correctly for multiple-selection listboxes under future versions of 
  160.     Windows.
  161.  
  162.     Example:
  163.         ...
  164.         If mlistbox1.ListIndex = -1 then     
  165.         ...
  166.  
  167.  
  168. SelCount -
  169.     Returns the number of selected items in the listbox.
  170.  
  171.     Example:
  172.         ...
  173.         For i=1 to mlistbox1.SelCount - 1
  174.         ...
  175.  
  176.     See Also:
  177.         SelCount, Selected
  178.  
  179.  
  180. Selected -
  181.     When read, this property returns a TRUE if the item is selected, 
  182.     otherwise a FALSE is returned.
  183.  
  184.     When writing, this property may be used to select (or deselect) an
  185.     item in the listbox.  For single-selection listboxes, if another item
  186.     is currently selected, the selection will change to a new item.  Also,
  187.     an item cannot be deselected in a single-selection listbox using this
  188.     property (use ListIndex instead).
  189.  
  190.     Example:
  191.         ...
  192.         for i=0 to mlistbox1.SelCount - 1
  193.             mlistbox1.Selected =  TRUE          ' select every item
  194.         next
  195.         ...
  196.  
  197.     See Also:
  198.         SelCount, SelList, ListIndex
  199.  
  200.  
  201. SelList -
  202.     The property is an array that contains the indexes of the currently
  203.     selected items in the listbox.  The first selected item is SelList(0), 
  204.     etc.
  205.  
  206.     Example:
  207.         ...
  208.         For i=0 to mlistbox1.SelCount - 1
  209.             if mlistbox1.list(mlistbox1.SelList(i)) = "John" then
  210.         ...
  211.  
  212.     See Also:
  213.         SelCount, Selected
  214.  
  215.  
  216. Style -
  217.     This property sets the style of the listbox (single-, extended-, or
  218.     multiple-selection).
  219.  
  220.     Style = 0: single-selection.  This type of listbox may only have one
  221.                item selected at a time.
  222.     Style = 1: extended-selection.  This type of listbox may have more than
  223.                one item selected.  The user must hold down the 'CTRL' or
  224.                'SHIFT' keys while clicking the mouse to select more than
  225.                one item
  226.     Style = 2: multiple-selection.  This type of listbox may have more than
  227.                one item selected.  The user does not need to hold down any
  228.                keys while selecting items.
  229.  
  230.     You should probably set the Style property at design time.  While you
  231.     may change the Style at run-time, doing so clears out the contents of
  232.     the listbox.
  233.  
  234.     Example:
  235.         CONST EXTENDED_SELECTION = 1
  236.         ...
  237.         mlistbox1.Style = EXTENDED_SELECTION
  238.         ...
  239.  
  240.  
  241. Tabs - (1.1)
  242.     A string that contains the location of tabs within the listbox.
  243.  
  244.     If you do not specify any tab locations (i.e. Tabs = ""), Windows
  245.     will automatically set a tab every 32 dialog units.
  246.  
  247.     If you specify only one tab, the listbox will have a tab at every
  248.     'n' dialog units.  For example:  Tabs = "10" will set a tab every
  249.     10 dialog units.
  250.  
  251.     For more than one tab, There will be a tab set at just the positions
  252.     that you specified, and then every 32 positions from then on.  For 
  253.     example:  Tabs = "10 20" will set a tab at 10, then at 20, then at
  254.     32, 64, etc.
  255.  
  256.     Example:
  257.         ...
  258.         t$ = Chr$(9)            ' Chr$(9) is a tab character
  259.         mlistbox1.additem "John" + t$ + "Doe"
  260.         ...
  261.  
  262.  
  263. Text -
  264.     For single-selection listboxes, Text returns the currently selected item
  265.     in the listbox.  For multiple-selection listboxes the item that was most
  266.     recently clicked is returned, you can then use the 'Selected', and 
  267.     'ListIndex' properties to determine if the item is selected or not.
  268.  
  269.     NOTE:  The Windows SDK says that this should not work for multiple-
  270.     selection listboxes; however, it seems to work fine under Windows 3.0.
  271.     Therefore, I cannot guarantee that this property will work correctly
  272.     for multiple-selection listboxes under future versions of Windows.
  273.  
  274.     Example: 
  275.         ...
  276.         if (mlistbox1.text = "John") then
  277.         ...
  278.  
  279.     See Also:
  280.         ListIndex, Selected
  281.  
  282.  
  283. TopIndex -
  284.     Sets the index of the item that is at the top of the listbox.   If you
  285.     try to set the top index to an item number less than 0, the listbox
  286.     will start from item 0.  If you try to use an index that is to high
  287.     the listbox will not change.
  288.  
  289.     Example:
  290.         ...
  291.         mlistbox1.TopIndex = mlistbox1.TopIndex + 1     ' Scroll by one line
  292.         ...
  293.  
  294.  
  295. Version - (1.1)
  296.     Version is a read-only property that returns the version of the MListbox 
  297.     custom control file.
  298.  
  299.     Any attempt to write to this property is simply ignored.
  300.  
  301.     NOTE: This property was not supported in version 1.0 of MListbox.
  302.  
  303.     Example:
  304.         ...
  305.         If mlistbox1.Version = 1.1 then
  306.         ...
  307.  
  308.                                 PROPERTIES                                
  309.                                 
  310. This is a comprehensive list of all properties supported by the control:
  311.  
  312.     CtlName     Index       BackColor   ForeColor   Left
  313.     Top         Width       Height      MousePointer
  314.     TabIndex    TabStop     DragIcon    DragMode    Enabled
  315.     Parent      Tag         Visible     FontName    FontBold
  316.     FontItalic  FontStrikethru          FontSize    FontUnder
  317.     ListCount   SelCount    ListIndex   TopIndex    List
  318.     Empty       SelList     Style       Text        Sorted
  319.     Selected    FindString  FindIndex   ItemData    hWnd
  320.     AutoRedraw  Tabs        Version
  321.  
  322.                                   EVENTS
  323.  
  324.     Click       DblClick    DragDrop    DragOver    GotFocus
  325.     KeyDown     KeyPress    KeyUp       LostFocus   MouseDown
  326.     MouseMove   MouseUp
  327.  
  328.                                  METHODS
  329.  
  330.     AddItem     RemoveItem  Refresh     Load        Unload
  331.  
  332.  
  333.                              VERSION HISTORY
  334.  
  335. 1.1   - Oct 25, 1992
  336.  
  337.         Fixed a bug relating to the Windows message WM_SETREDRAW.
  338.         Fixed a bug relating to the background color while in design mode.
  339.  
  340.         Added the AutoRedraw, Tabs, and Version properties.
  341.  
  342.         Verified compatibility with Windows 3.1
  343.         Converted from MS QC/Win 1.0 to MS C 7.00
  344.  
  345. 1.0   - February 16, 1992
  346.  
  347.         Initial release
  348.  
  349.  
  350.                             DISTRIBUTION RIGHTS
  351.  
  352. You are free to distribute this product separately from a product of your
  353. own, as long as you distribute both this file, and the custom control file
  354. (MLISTBOX.VBX).
  355.  
  356. If you wish to use this product in one of your own products, your rights
  357. depend on what sort of product it is:
  358.  
  359. Public Domain:  i.e. not for profit, you ask no monetary fee for someone
  360. to use your product.  In this case, you are free to distribute this control
  361. as much as you wish.
  362.  
  363. Shareware:  i.e. requesting that the user send you some money if they 
  364. like/use your product.  In this case, please send me a postcard of your
  365. home town or some feature thereabouts.
  366.  
  367. Commercial:  i.e. for profit.  In this case, please contact me (see below),
  368. and we can arrange some mutually beneficial agreement.
  369.  
  370.  
  371. I may be reached either through e-mail at:
  372.  
  373.     warninm@xanth.cs.orst.edu
  374.  
  375. or through regular mail at:
  376.  
  377.     Mike Warning
  378.     6015 202nd St. S.W. #14
  379.     Lynnwood, WA 98036
  380.  
  381. If you wish a prompt reply, please use e-mail.  I do not actually live at
  382. the mailing address above, and it may take weeks/months to get anything to
  383. me that is sent there.
  384.  
  385.